/*! @file defines.h
  * @brief Definitions and inline methods in here
  * @author AK
  * @date 21.06.2012
  */

#ifndef DEFINES_H
#define DEFINES_H

#include <QtGui/QtGui>

const int TRUE = 1;

//! @namespace DbDlg just defines in here
namespace DbDlg
{
const int DLG_FILE =    3;      //! < DLG_FILE Definition
const int DLG_FOLDER =  4;      //!< DLG_FOLDER Definition
const int DLG_NOFORCE = 1;      //!< DLG_NOFORCE Definition
const int DLG_FORCE =   2;      //!< DLG_FORCE Definition
const int DLG_OKBTN =   5;      //!< DLG_OKBTN Definition
}   // namespace DbDlg

//! @namespace FileType just defines in here
namespace FileType
{
const int FT_FIREFOX = 1;           //!< FT_FIREFOX Definition
const int FT_FIREFOX_PLACES = 101;   //!< FT_FIREFOX_PLACES Definition
const int FT_FIREFOX_SIGNONS = 102;  //!< FT_FIREFOX_SIGNONS
const int FT_ANDROID = 2;           //!< FT_ANDROID Definition
const int FT_ANDROID_MMS = 201;     //!< FT_ANDROID_MMS Definition
const int FT_OTHER =   3;           //!< FT_OTHER Definition
const int FT_APPLE =   4;           //!< FT_APPLE Definition
const int FT_CHROME =  5;           //!< FT_CHROME Definition
const int FT_EMPTY = -95;           //!< FT_EMPTY Definition
const int FT_NOTABLE = -97;         //!< FT_NOTABLE Definition
const int FT_INVALID = -99;         //!< FT_INVALID Definition
}   // namespace FileType

//! @namespace ItemRole Is it topLevel, File or Tableentry
namespace ItemRole
{
const int IR_TOPLEVEL = 10;     //! IR_TOPLEVEL Definition
const int IR_FILE =     11;     //! IR_FILE Definition
const int IR_TABLE =    12;     //! IR_TABLE Definition
const int IR_FIELD =    13;     //! IR_FIELD Definition
} // namespace ItemRole

//! @brief struct ResultSet holds results of query
struct ResultSet {
    int rc;
    QString sql;
    char **results;
    int rows;
    int columns;
    double size;
    int caller;

    operator QVariant() const {
        return QVariant::fromValue(*this);
    }
}; // struct ResultSet
Q_DECLARE_METATYPE(ResultSet);

//! @brief struct DbDetails holds Name and intId of checked Db
struct DbDetails {
    QString detailsName;    // Itemname
    int detailsId;          // Itemid
    int detailsRole;        // is Item topLevel, file or tableentry

    operator QVariant() const {
        return QVariant::fromValue(*this);
    }
};  // struct DbDetails
Q_DECLARE_METATYPE(DbDetails);

//! @brief overloads << for qDebug()
inline QDebug operator<<(QDebug debug, const DbDetails& dbdetails)
{
    debug.nospace() << "DbDetails("
                    << dbdetails.detailsName << ", "
                    << dbdetails.detailsId << ", "
                    << dbdetails.detailsRole << ")";
    return debug.space();
}


// for binaryViewWidget
//
const int pagesize = 2048;

// predefined sql queries
//
const QString g_sqlListTables = "SELECT name \nFROM sqlite_master \nWHERE type='table';";   //!< sqlListTables
const QString g_sqlEmpty = "SELECT * ;";                                                    //!< sqlEmpty
const QString g_sqlListViews = "SELECT *\n" \
                         "FROM sqlite_master\n" \
                         "WHERE type = 'view';";
const QString ff_sqlTypedUrlSorted = "SELECT url, typed AS 'typed URLs', visit_count\n" \
                               "FROM moz_historyvisits, moz_places\n" \
                               "WHERE typed=1\n" \
                               "AND moz_historyvisits.place_id=moz_places.id\n" \
                               "ORDER BY visit_count desc;";                        //!< f_sqlTypedUrlSorted
const QString ff_sqlHistory = "SELECT datetime(moz_historyvisits.visit_date/1000000,'unixepoch') AS date, \n" \
        "moz_places.url, moz_places.title, moz_places.typed, moz_places.frecency, \n" \
        "datetime(moz_places.last_visit_date/1000000,'unixepoch') AS last_visit_date \n" \
        "FROM moz_places, moz_historyvisits \n" \
        "WHERE moz_places.id = moz_historyvisits.place_id;";
const QString ff_sqlSignons = "SELECT hostname, usernameField, passwordField, \n" \
        "encryptedUsername, encryptedPassword, encType, \n" \
        "(SELECT datetime(moz_logins.timeCreated/1000, 'unixepoch')) AS timeCreated, \n" \
        "(SELECT datetime(moz_logins.timeLastUsed/1000, 'unixepoch')) AS timeLastUsed, \n" \
        "timesUsed FROM moz_logins;";
const QString an_sqlMessages = "";

#endif // DEFINES_H
